package com.spzx.cart.api.factory;

import com.baomidou.mybatisplus.core.metadata.OrderItem;
import com.spzx.cart.api.RemoteCartService;
import com.spzx.cart.api.domain.CartInfo;
import com.spzx.common.core.domain.R;
import com.spzx.common.core.web.domain.AjaxResult;
import lombok.extern.slf4j.Slf4j;
import org.bouncycastle.LICENSE;
import org.springframework.cloud.openfeign.FallbackFactory;
import org.springframework.stereotype.Component;

import java.util.List;

/**
 * ClassName: RemoteCartFallbackFactory
 * Package: com.spzx.cart.api.factory
 * Description:
 */
@Component
@Slf4j
public class RemoteCartFallbackFactory implements FallbackFactory<RemoteCartService> {
    @Override
    public RemoteCartService create(Throwable cause) {
        log.error("调用购物车失败:{}",cause.getMessage());
        return new RemoteCartService() {
            @Override
            public R updateCartPrice(String source) {
                return R.fail("调用购物车失败:"+cause.getMessage());
            }

            @Override
            public R<List<CartInfo>> getCheckList(Long userId, String source) {
                return R.fail("调用购物车失败:"+cause.getMessage());
            }

            @Override
            public AjaxResult deleteCart(List<Long> skuId, String source) {
                return AjaxResult.error("调用购物车失败:"+cause.getMessage());
            }
        };
    }
}
